package com.ggs.rg.ybjb.systemmodule.service;

import com.alibaba.fastjson.JSONObject;
//import com.ggs.rg.ybjb.systemmodule.service.impl.AdminServiceImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * ClassName:AdminService
 * Package:com.ggs.rg.ybjb.systemmodule.service
 * Description:
 *
 * @Date:2021/11/3 22:05
 * @Author:cxw
 */
//,fallback = AdminServiceImpl.class
@FeignClient("adminModule")
public interface AdminService {

    //获得公告
    @GetMapping("/tacModule/getTAC")
    public JSONObject getATC();

    //模块之间传输文件,需要在@PostMapping注解设置consumes = MediaType.MULTIPART_FORM_DATA_VALUE,说明要传输文件
    //传递到服务提供者的文件参数前需要加@RequestPart("p1")
    @PostMapping(value="/tacModule/addTAC",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public JSONObject addTAC(@RequestPart("p1")MultipartFile p1, @RequestParam("text")String text);

    //删除公告
    @PostMapping("/tacModule/deleTAC")
    public JSONObject deleTAC(JSONObject jsonObject);

    //更新公告
    @PostMapping(value="/tacModule/updateTAC",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public JSONObject updateTAC(@RequestParam("id")Integer id,
                                @RequestParam("text")String text,
                                @RequestPart("p1")MultipartFile p1);

    //查询所有订单
    //完整的信息包括:订单基本信息,收货地址,购买的商品信息(可能有多个),这个接口返回的订单信息只是基本信息,没有购买的商品信息
    @GetMapping("/orderModule/getOrders")
    public JSONObject getOrders(@RequestParam("pagesNumber") Integer pagesNumber,@RequestParam("status") Integer status);


    //根据oid获取订单
    @GetMapping("/orderModule/getOrderById")
    public JSONObject getOrderById(@RequestParam("oid") Long oid);

    //根据oid获取订单详情
    @GetMapping("/orderModule/getOrderDetailById")
    public JSONObject getOrderDetailsById(@RequestParam("oid") Long oid);

    //添加订单
    @PostMapping("/orderModule/addOrder")
    public JSONObject addOrder(@RequestBody JSONObject params);

    //获取总订单数
    @GetMapping("/orderModule/getOrderCount")
    public JSONObject getOrderCount();

    //获取总交易金额
    @GetMapping("/orderModule/transactionAmount")
    public JSONObject transactionAmount();

    //获取所有用户的基本信息
    @GetMapping("/userModule/getUsers")
    public JSONObject getUsers(@RequestParam(value = "pagesNumber") Integer pagesNumber);

    //获取系统用户总数
    @GetMapping("/userModule/getUserCount")
    public JSONObject getUserCount();

    //获取手机号获取用户详情
    @GetMapping("/userModule/getUserDeatilById")
    public JSONObject getUserDeatilById(@RequestParam(value = "phone",required = false) String phone);

    //删除商品，连带着商品参数一起删除
    @PostMapping("/goodsModule/deleteGoods")
    public JSONObject deleteAllGoods(@RequestParam("gid")Integer gid);

    //删除商品某一个参数值
    @PostMapping("/goodsModule/deleteMater")
    public JSONObject deleteGoodsMater(@RequestParam("pid")Integer pid);

    //查询商品 or 参数表关联的商品内容
    @GetMapping("/goodsModule/selectGoodsMater")
    public JSONObject selectGoodsAndMater(@RequestParam("gid")Integer gid);

    //模糊查询
    @PostMapping("/goodsModule/selectLike")
    public JSONObject selectLike(@RequestParam("name")String name,@RequestParam("pagesNumber")Integer pagesNumber);

    //获取所有商品，不包含参数  商品数量包含在里面
    @GetMapping("/goodsModule/selectGoods")
    public JSONObject selectGoods(@RequestParam(value = "pagesNumber",required = false) Integer pagesNumber);

    //添加库存
    @PostMapping("/goodsModule/addCount")
    public JSONObject addCount(@RequestParam("cid")Integer cid,@RequestParam("count")Integer count);

    //获取所有评论
    @GetMapping("/commentModule/selectTComment")
    public JSONObject selectTComment(@RequestBody JSONObject jsonObject);

    //发布评论,用户只能在一个商品发布一个评论，管理员也只能回复一次。
    @PostMapping(value = "/commentModule/addUserComment",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public JSONObject addUserComment(@RequestPart("p1") MultipartFile p1,
                                     @RequestParam("text") String text,
                                     @RequestParam("gid") Integer gid,
                                     @RequestParam("phone") String phone);

    //商家回复评论
    @PostMapping("/commentModule/addComment")
    public JSONObject addComment(@RequestParam("cid")Integer cid,@RequestParam("textManage")String textManage);

    @PostMapping(value="/goodsModule/addGoods",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public JSONObject addGoods(@RequestParam("name") String name,
                               @RequestParam("gDesc")String gDesc,
                               @RequestParam("status") Integer status,
                               @RequestParam("type") String type,
                               @RequestPart("p1") MultipartFile p1,
                               @RequestParam("goodsList") String goodsList);

    //管理端首页数据展示
    //首页数据  获取前七天数据（订单数量、订单总金额）
    @GetMapping("/orderModule/getOrderData")
    public JSONObject getOrderData();

    //查询缺货商品
    @GetMapping("/goodsModule/selectBackorder")
    public JSONObject selectBackorder(@RequestParam(value = "pagesNumber",required = false) Integer pagesNumber);

    //模糊查询缺货商品
    @PostMapping("/goodsModule/selectBackorderLike")
    public JSONObject selectBackorderLike(@RequestParam("name")String name,@RequestParam("pagesNumber")Integer pagesNumber);

}
